
#ifndef __KVSTORE_H__
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <assert.h>

#define __KVSTORE_H__
#define BUFFER_LENGTH 512
typedef int (*RCALLBACK)(int fd);
typedef struct conn_item
{
    int fd;

    // char *rbuffer;
    // char *wbuffer;
    char rbuffer[BUFFER_LENGTH];
    char wbuffer[BUFFER_LENGTH];
    unsigned int rlen;
    unsigned int wlen;

    union
    {
        RCALLBACK recv_callback;
        RCALLBACK accept_callback;
    } recv_t;
    RCALLBACK send_callback;
};

int epoll_entry(void);
int ntyco_entry(void);
// int iouring_entry(void);
int kvstore_request(struct conn_item *item);
void *kvstore_malloc(size_t size);
void kvstore_free(void *ptr);

#define NETWORK_EPOLL		0
#define NETWORK_NTYCO		1
#define NETWORK_IOURING		2


#define ENABLE_ARRAY_KVENGINE 1
#define ENABLE_NETWORK_SELECT	NETWORK_NTYCO

#if ENABLE_ARRAY_KVENGINE
#define KVS_ARRAY_SIZE 1024
struct kvs_array_item
{
    char *key;
    char *value;
};
char *kvstore_array_get(char *key);
int kvstore_array_set(char *key, char *value);
#endif

#endif